<template>
  <default-home-card icon="Profile" title="销量统计">
    <div class="echarts-box">
      <div class="category-main" id="category-main"></div>
    </div>
  </default-home-card>
</template>
<script setup>
  import DefaultHomeCard from '/@/views/system/home/components/default-home-card.vue';
  import * as echarts from 'echarts';
  import { reactive, ref,onMounted } from 'vue';
  import { orderApi } from '/@/api/business/order/order-api';
    const option = ref({
      xAxis: {
        type: 'category',
        data: ['周一', '周二', '周三', '周四', '周五'],
      },
      yAxis: {
        type: 'value',
      },
      legend: {},
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true,
      },
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'shadow',
        },
      },
      series: [
        {
          name: '代取快递',
          data: [120, 200, 150, 80, 70, 110, 130],
          type: 'bar',
          backgroundStyle: {
            color: 'rgba(180, 180, 180, 0.2)',
          },
        },
        {
          name: '代买物品',
          data: [100, 80, 120, 77, 52, 22, 190],
          type: 'bar',
          backgroundStyle: {
            color: 'rgba(180, 180, 180, 0.2)',
          },
        },
        {
          name: '代取外卖',
          data: [200, 110, 85, 99, 120, 145, 180],
          type: 'bar',
          backgroundStyle: {
            color: 'rgba(180, 180, 180, 0.2)',
          },
        },
        {
          name: '代办事',
          data: [80, 70, 90, 110, 200, 44, 80],
          type: 'bar',
          backgroundStyle: {
            color: 'rgba(180, 180, 180, 0.2)',
          },
        },
      ],
    });

  onMounted(() => {
    init();
  });
  function init() {
    let chartDom = document.getElementById('category-main');
    if (chartDom) {
      let myChart = echarts.init(chartDom);
      option.value && myChart.setOption(option.value);
    }
  }
    async function ajaxQuery() {
    try {
      tableLoading.value = true;
      //调用查询方法
      let responseModel = await orderApi.queryNum();
      const list = responseModel.then(result => {return responseModel.data} );
      console.log(list)  
      // for (const item of list)
      // {
      //   item.shopRangeName = _.join(item.shopRangeName, ',');
      // }
      // console.info('list='+JSON.stringify(list))
      total.value = responseModel.data.total;
      tableData.value = list;
      // // 清除选中
      // selectedRowKeys.value = [];
      // selectedRows.value = [];
    } catch (e) {
      smartSentry.captureError(e);
    } finally {
      tableLoading.value = false;
    }
  }
</script>
<style lang="less" scoped>
  .echarts-box {
    display: flex;
    align-items: center;
    justify-content: center;
    .category-main {
      width: 1600px;
      height: 280px;
      background: #fff;
    }
  }
</style>
